package com.mofum.msdom.excel.demo.expression;

import com.mofum.msdom.excel.constant.TemplateConfig;

import java.util.List;

/**
 * @author yuyang@qxy37.com
 * @since 2019/2/1 0001 17:26
 */
public class Test {

    public static void main(String[] args) {

        String formattedValue = "${ prop.el.name  }$ cascs ${ssda.ccas.cc}$";

        TemplateConfig templateConfig = TemplateConfig.DEFAULT_CONFIG;

        //表达式处理
        boolean hasExpression = TemplateConfig.isHasItemRegExpressions(templateConfig.getItemReg(), formattedValue);

        String resultValue = formattedValue;


        if (hasExpression) {
            List<String> codes = TemplateConfig.getMatcher(templateConfig.getItemReg(), formattedValue);

            resultValue = TemplateConfig.replaceReg(templateConfig.getExtractReg(), formattedValue);

            for (String code : codes) {

                String propName = TemplateConfig.replaceName(templateConfig.getExtractReg(), code);

                resultValue = TemplateConfig.replaceSingleProp(propName, resultValue,"1123");
            }

        }

        System.out.println(resultValue);

    }


}
